#include "../logger/log.h"

void test_log(const std::string &logger_name) {
    INFO("%s", "测试开始");
    log::Logger::ptr logger = log::LoggerManager::get_instance().get_logger(logger_name);
    if (logger.use_count() == 0) return;
    logger->debug("%s", "未禾");
    logger->info("%s", "未禾");
    logger->warn("%s", "未禾");
    logger->error("%s", "未禾");
    logger->fatal("%s", "未禾");
    DEBUG_LOG(logger, "%s", "未禾");
    INFO_LOG(logger, "%s", "未禾");
    WARN_LOG(logger, "%s", "未禾");
    ERROR_LOG(logger, "%s", "未禾");
    FATAL_LOG(logger, "%s", "未禾");
    size_t count = 0;
    while (count <= 200000) {
        logger->fatal("测试日志-%d", count++);
    }
    
    INFO("%s", "测试完毕");
}

int main() {
    // <全局异步日志器测试>
    std::unique_ptr<log::LoggerBuilder> builder(new log::GlobalLoggerBuilder);
    builder->build_logger_name("sync-logger");
    builder->build_Formatter("[%c][%f:%l][%d{%H:%M:%S}]%m%n");
    builder->build_logger_type(log::LoggerType::SYNC_LOGGER);
    builder->build_sink<log::StdoutLogSink>();
    builder->build_sink<log::FileLogSink>("./logfile/sync.log");
    builder->build_sink<log::RollBySizeLogSink>("./logfile/roll-sync-by-size-", 1024 * 1024);
    builder->build();
    test_log("sync-logger");
    // <全局异步日志器测试>
    return 0;
}
